package com.citi.xylophone.phoneEmulator.audio;


import java.util.List;



import com.citi.xylophone.phoneEmulator.model.SourceAudio;
import com.citi.xylophone.phoneEmulator.view.MainPanelview;

public class AudioManager {
	
	static private AudioThread audioThread = null;
	static private MainPanelview mainPanelview;
	
	
	
	
	
	public static void setMainPanelview(MainPanelview mainPanelview) {
		AudioManager.mainPanelview = mainPanelview;
	}

	public static void playAudio(List<SourceAudio> listSourceAudio) throws Exception{
		
		if (audioThread != null && audioThread.isAlive()){
			audioThread.stopAudioThread();
		}
		
		audioThread = new AudioThread(listSourceAudio);
		audioThread.setMainPanelview(mainPanelview);
		audioThread.start();
		
	}
	
	public static void stopAudio() throws Exception{
		
		if (audioThread != null && audioThread.isAlive()){
			audioThread.stopAudioThread();
		}
	}
}
